var { ReturnModel } = require('../libs/resmodel');
var {buildQrcode} = require('../services/qrcode');
var {mybuildreport} = require('../services/wechat');

const immessage = require('../services/immessage').immessageSync;
/**
* 测试接口联通
* @api {get} /test 测试接口联通
* @apiDescription 测试接口联通
* @apiName test
* @apiSampleRequest /test
* @apiGroup test-测试接口联通
* @apiVersion 1.0.0
* @apiSuccessExample {json} Success-Response:
*   HTTP/1.1 200 OK
*    {
*      "data":"",
*      "msg":"接口已联通！！！",
*      "code":0
*    }
*/
function test(req, res) {
  res.json(new ReturnModel('接口已联通！！！'));
}
function immsgSync(req,res){
  let result = immessage(req);
  res.json(result);
}
function immsgSyncget(req,res){
  res.json({
    "code":200,
    "content":"success"
  });
}
function test2(req, res){
  let qrcode = mybuildreport(null);
  res.json(new ReturnModel('ok！！！'));
}
function test3(req, res){
  let qrcode = mybuildreport('841646873037');
  res.json(qrcode);
}

module.exports = function (app) {
  app.get('/api/test', test);
  app.get('/api/test2', test2);
  app.get('/api/test3', test3);
  app.post('/api/immsgSync', immsgSync);
  app.get('/api/immsgSync', immsgSyncget);
}
